package org.orman.sql;

public enum QueryType {
	SELECT("SELECT {SELECT_COLUMN_LIST} FROM {TABLE_LIST} {JOIN}{WHERE}{GROUP_BY}{HAVING}{ORDER_BY}{LIMIT}"),
	SELECT_DISTINCT("SELECT DISTINCT {SELECT_COLUMN_LIST} FROM {TABLE_LIST} {JOIN}{WHERE}{GROUP_BY}{HAVING}{ORDER_BY}{LIMIT}"),
	
	INSERT("INSERT INTO {TABLE_LIST} ({COLUMN_LIST}) VALUES ({VALUE_LIST})"),
	
	UPDATE("UPDATE {TABLE_LIST} SET {COLUMN_VALUE_LIST} {WHERE}"),
	
	DELETE("DELETE FROM {TABLE_LIST} {WHERE}"),
	
	CREATE_TABLE("CREATE TABLE {TABLE_LIST} ({COLUMN_OR_CONSTRAINT_DESCRIPTION_LIST})"),
	CREATE_TABLE_IF_NOT_EXSISTS("CREATE TABLE IF NOT EXISTS {TABLE_LIST} ({COLUMN_OR_CONSTRAINT_DESCRIPTION_LIST})"),
	DROP_TABLE("DROP TABLE {TABLE_LIST}"),
	DROP_TABLE_IF_EXISTS("DROP TABLE IF EXISTS {TABLE_LIST}"),
	
	CREATE_INDEX("CREATE INDEX {INDEX_NAME} ON {TABLE_LIST} ({SELECT_COLUMN_LIST})"),
	CREATE_UNIQUE_INDEX("CREATE UNIQUE INDEX {INDEX_NAME} ON {TABLE_LIST} ({SELECT_COLUMN_LIST})"),
	CREATE_INDEX_IF_NOT_EXISTS("CREATE INDEX IF NOT EXISTS {INDEX_NAME} ON {TABLE_LIST} ({SELECT_COLUMN_LIST})"),
	CREATE_UNIQUE_INDEX_IF_NOT_EXISTS("CREATE UNIQUE INDEX IF NOT EXISTS {INDEX_NAME} ON {TABLE_LIST} ({SELECT_COLUMN_LIST})"),
	DROP_INDEX("DROP INDEX {INDEX_NAME}"), // TODO is it necessary to use ON clause?
	DROP_INDEX_IF_EXISTS("DROP INDEX IF EXISTS {INDEX_NAME} "), // TODO is it necessary to use ON clause?
	
	USE_DATABASE("USE DATABASE {DATABASE}"),
	
	CREATE_VIEW("CREATE VIEW {SELECT_COLUMN_LIST}"),
	
	BEGIN_TRANSACTION("BEGIN"),
	COMMIT_TRANSACTION("COMMIT"),
	ROLLBACK_TRANSACTION("COMMIT");
	
	private String template;

	private QueryType(String tpl) {
		this.template = tpl;
	}

	public String getTemplate() {
		return this.template.toString();
	}
}